import React, { useReducer } from 'react';

const myApproval = React.createContext();

const stateAll = {
    financialApplyType: 1 
}

//更改我的线索类型
function reducer(state = stateAll, action) {
    let newState = JSON.parse(JSON.stringify(state));
    switch(action.type) {
        case 'financialApplyType':
            newState.financialApplyType = action.financialApplyType;
            return newState;
        default:
            return state;
    }
}

const ContextMyApproval = props => {
    const [state, dispatch] = useReducer(reducer, stateAll);
    return <myApproval.Provider value = {{state, dispatch}}>
        {props.children}
    </myApproval.Provider>
}

export { reducer, myApproval, ContextMyApproval}